#! /usr/bin/env python
# -*- coding: utf-8 -*-


class DemoField:

    def __init__(self, initval=None, name='val'):
        print('init initval', initval)
        print('init name', name)
        self.val = initval
        self.name = name

    def __get__(self, obj, type_):
        print('get obj', obj)
        print('get type', type_)
        return self.val

    def __set__(self, obj, val):
        print('set obj', obj)
        print('set val', val)
        self.val = val

    def __set_name__(self, obj, name):
        print('set_name obj:', obj)
        print('set_name name:', name)
        self.name = name


class Demo:
    f = DemoField()


d = Demo()
print(d.f)
print('------------')
d.f = 5
print('------------')
print(d.f)
